#include <iostream>
#include <cmath>

using namespace std;

int main() {
    int a =0,d = 0,b=0,c=0;
    cin >> a;
    int n;
    for(int i = 1; i <= a;i++){
    	n = 0;
    	c = 0;
    	b = 0;
    	int n2 = 0;
    	while(pow(10,n2)<= i){
    		n2++;
		}
		n2--;
		while(pow(10,n) <= i){
	        b = (int)(i / pow(10,n)) % 10;
	        c += b * pow(10,n2-n-1); 
	        n += 1; 
	        
    	}
    	if (i == c){
    		cout << i << endl;
		}
	}
    return 0;
}
